import request from '@/utils/request'

export default {
    list(page, limit, name) {
        return request({
            url: `/role/list/${page}/${limit}`,
            method: 'get',
            params: { name }
        })
    },

    removeById(id) {
        return request({
            url: `/role/removeById/${id}`,
            method: 'delete',
        })
    },

    removeByIds(ids) {
        return request({
            url: `/role/removeByIds`,
            method: 'delete',
            data: ids
        })
    },

    add(role) {
        return request({
            url: `/role/add`,
            method: 'post',
            data: role
        })
    },

    update(role) {
        return request({
            url: `/role/update`,
            method: 'post',
            data: role
        })
    },

    getRoleById(id) {
        return request({
            url: `/role/getById/${id}`,
            method: 'get',
        })
    },

    // 获取用户的角色
    getUserRole(id) {
        return request({
            url: `/user/getByUserId/${id}`,
            method: 'get',
        })
    },

    // 分配角色
    assignRole(po) {
        return request({
            url: `/user/assignRole`,
            method: 'post',
            data: po
        })
    }

}

